package utils;

import com.alibaba.fastjson.JSON;

import domain.People;

public class ParsingUtil {
	public static People parsingJSON(String json) {

		return JSON.parseObject(json, People.class);
	}

	public static People parsingExcel(String message) {
		People people = new People();
		String[] strings = message.split("\n");
		for (int i = 1; i < strings.length - 1; i++) {
			String[] strings1 = strings[i].split(" ");
			people.setName(strings1[0]);
			people.setAge(Integer.parseInt(strings1[1].substring(0, 2)));
			people.setSex(strings1[2]);
			people.setTelephone(strings1[3].substring(1));
		}
		return people;
	}

	public static People parsingTxt(String message) {
		People people = new People();
		String[] strings = message.split(",");
		people.setName(strings[0].split("=")[1]);
		people.setAge(Integer.parseInt(strings[1].split("=")[1]));
		people.setSex(strings[2].split("=")[1]);
		people.setTelephone(strings[3].split("=")[1].replaceAll(".txt", ""));
		return people;

	}
}